home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!nix
- From: nix@teleport.com (Jonathan Nix)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] Dynamically allocating memory for a char*
- Date: 20 Jan 1996 06:57:53 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4dq3ph$cu1@maureen.teleport.com>
- References: <4dmn1i$10t@walrus2.walrus.com>
- NNTP-Posting-Host: julie.teleport.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Felipe Jordao (fjordao@walrus.com) wrote:
- : Hi,
-
- : I have a question about allocating memory for a string as it's passed
- : in by the user. I'm using cin to get the info, but maybe this is
- : inappropriate. I have included the relevant snippets of the file
- : below. What I am trying to achieve is no limitation for the user when
- : they input a path + filename. Is it possible to use char* foo and
- : then something like (I know this is wrong, but the idea of it ...)
-
- : cin >> malloc(sizeof(infile)); :0
- Get a load of this next snippet.. it's a way to conveniently work
- around your problem, by using an unused (while in text mode) portion of
- the video memory (or hopefuly unused.. works for DOS/Win95). You have
- 64,000 bytes to work with pal.
-
- #include <iostream.h>
- void main(void)
- {
- char far *vptr = (char far *)0xA0000000L;
- cin >> vptr;
- cout << vptr << endl;
- }
-
- Don't fear any anomolies.. no other program should be using this
- space, and even if one is, it should be remapped in Win95. (Don't know
- about OS/2) UN*X users will get a SIGSEGV.
-
- Jonathan Darren
-